package geometry3D;

import context.*;

import java.awt.geom.Point2D;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;


// ********************************************************************
// *** CLASS: Point3D
// ********************************************************************
public class Point3D implements Context.Constants
{ //private static final boolean DEBUG=true; // Overriding Context.Constants.DEBUG
  public double x;
  public double y;
  public double z;

  public Point3D(double x,double y,double z)
  { this.x=x; this.y=y; this.z=z; }

  public Point3D addX(double dx) { return(new Point3D(x+dx,y,z)); }
  public Point3D addY(double dy) { return(new Point3D(x,y+dy,z)); }
  public Point3D addZ(double dz) { return(new Point3D(x,y,z+dz)); }

  public Point2D.Double getXZ(Point2D.Double origo2D,double scale)
  { double x1=origo2D.x+this.x;
    double y1=origo2D.y+this.z;
    return(new Point2D.Double(x1*scale,y1*scale));
  }

  public Point2D.Double getXY(Point2D.Double origo2D,double scale)
  { double x1=origo2D.x+this.x;
    double y1=origo2D.y+this.y;
    return(new Point2D.Double(x1*scale,y1*scale));
  }

  public Point2D.Double getZY(Point2D.Double origo2D,double scale)
  { double x1=origo2D.x+this.z;
    double y1=origo2D.y+this.y;
    return(new Point2D.Double(x1*scale,y1*scale));
  }
  
  public Vector3f toVector3f() { return(new Vector3f((float)x,(float)y,(float)z)); }
  
  public Point3f toPoint3f() { return(new Point3f((float)x,(float)y,(float)z)); }

  public String toString()
  { return("Point3D[x="+x+",y="+y+",z="+z+']'); }
}
